home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 …ember: Reference Library / Apple Developer Reference Library (December 1999) (Disk 1).iso / pc / what's new / sample code / human interface toolbox / htmlsample / ciconbuttons.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-22  |  3.8 KB  |  119 lines

  1. /*
  2.     file CIconButtons.h
  3.     
  4.     Description:
  5.     This file contains type declarations, constants, and routine prototypes
  6.     for accessing the routines implemented in CIconButtons.c.  These routines
  7.     are used to implement the color icon buttons displayed in the top of
  8.     HTMLSample's windows.
  9.     
  10.     HTMLSample is an application illustrating how to use the new
  11.     HTMLRenderingLib services found in Mac OS 9. HTMLRenderingLib
  12.     is Apple's light-weight HTML rendering engine capable of
  13.     displaying HTML files.
  14.  
  15.     by John Montbriand, 1999.
  16.  
  17.     Copyright: © 1999 by Apple Computer, Inc.
  18.     all rights reserved.
  19.     
  20.     Disclaimer:
  21.     You may incorporate this sample code into your applications without
  22.     restriction, though the sample code has been provided "AS IS" and the
  23.     responsibility for its operation is 100% yours.  However, what you are
  24.     not permitted to do is to redistribute the source as "DSC Sample Code"
  25.     after having made changes. If you're going to re-distribute the source,
  26.     we require that you make it clear in the source that the code was
  27.     descended from Apple Sample Code, but that you've made changes.
  28.     
  29.     Change History (most recent first):
  30.     10/16/99 created by John Montbriand
  31. */
  32.  
  33. #ifndef __CICONBUTTONS__
  34. #define __CICONBUTTONS__
  35.  
  36. #include <Types.h>
  37.  
  38.     /* these are the resource types we use.  ResEdit
  39.     templates for these resource types are defined in
  40.     the application's resource fork. */
  41. enum {
  42.     kIconButtonIDListType = 'RBCL',
  43.     kIconButtonType = 'CICB'
  44. };
  45.  
  46.     /* buttons have three states, and three icons
  47.     for each of those states.  disabled is how it looks
  48.     when it cannot be clicked, up and down define
  49.     how it looks in each of those states. */
  50. enum {
  51.     kCBdisabled = 0,
  52.     kCBup = 1,
  53.     kCBdown = 2
  54. };
  55.  
  56. #pragma options align=mac68k
  57. typedef struct {
  58.     Rect bounds;
  59.     short drawnstate;
  60.     short cicnIDs[3]; /* resource id's for each state's cicn
  61.                 resource.  indexes in this array map to the
  62.                 states defined above. */
  63.     char stringdata[1]; /* variable size c string */
  64. } CIconButton, **CIconButtonHandle;
  65. #pragma options align=reset
  66.  
  67.  
  68. /* NewCIconButton retrieves a new color icon button
  69.     resource from the resource file.  the id number
  70.     corresponds to the resource id of the CICB resource. */
  71. CIconButtonHandle NewCIconButton(short id);
  72.  
  73.  
  74. /* DisposeCIconButton disposes of any structures allocated
  75.     for the color icon button allocated by NewCIconButton. */
  76. void DisposeCIconButton(CIconButtonHandle cicb);
  77.  
  78.  
  79. /* SetCIconButtonPosition sets the color icon button's 
  80.     screen postion. h and v are coordinates in the
  81.     current grafport. */
  82. void SetCIconButtonPosition(CIconButtonHandle cicb, short h, short v);
  83.  
  84.  
  85. /* GetCIconButtonStringData returns a new handled containing
  86.     the string data copied from the color icon resource.  The
  87.     handle will contain a C-style string terminated with a zero
  88.     byte.  It is the caller's responsibility to dispose of this
  89.     handle after it has been used. */
  90. OSErr GetCIconButtonStringData(CIconButtonHandle cicb, Handle *strdata);
  91.  
  92.  
  93. /* DrawCIconButton draws the icon button using the
  94.     as it should appear given the state specified.  state
  95.     should be either kCBdisabled, kCBup, or kCBdown.
  96.     The last state a button is drawn in affects the
  97.     result of TrackCIconButton. */
  98. void DrawCIconButton(CIconButtonHandle cicb, short state);
  99.  
  100.  
  101. /* TrackCIconButton should be called whenever a click is made
  102.     inside of a color icon button.  if the last time the button
  103.     was drawn its state was not kCBup or the click is outside
  104.     of the button, then this routine returns false. */
  105. Boolean TrackCIconButton(CIconButtonHandle cicb, Point where);
  106.  
  107. /* RBCLRsrcHandle defines the resource type used to store
  108.     a list of color icon button resource IDs.  In this example,
  109.     the user configurable button ids are stored in a RBCLRsrcHandle
  110.     resource. */
  111. #pragma options align=mac68k
  112. typedef struct {
  113.     short n;
  114.     short ids[1];
  115. } RBCLResource, **RBCLRsrcHandle;
  116. #pragma options align=reset
  117.  
  118. #endif
  119.